//
//  SearchTripsTableViewCell.m
//  HappinessTrip
//
//  Created by dllo on 15/10/21.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "SearchTripsTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "Fit.h"

@implementation SearchTripsTableViewCell
-(void)dealloc
{
    [_backImageView release];
    [_ImageView release];
    [_nameLabel release];
    [_timeLabel release];
    [_dianLabel release];
    [_mailLabel release];
    [_likeLabel release];
    [_youImageView release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}
-(void)createViews
{
    _backImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:_backImageView];
    [_backImageView release];
    _ImageView = [[UIImageView alloc]init];
    [_backImageView addSubview:_ImageView];
    [_ImageView release];
    _nameLabel = [[UILabel alloc]init];
    [_backImageView addSubview:_nameLabel];
    [_nameLabel release];
    _timeLabel = [[UILabel alloc]init];
    [_backImageView addSubview:_timeLabel];
    [_timeLabel release];
    _dianLabel = [[UILabel alloc]init];
    [_backImageView addSubview:_dianLabel];
    [_dianLabel release];
    _mailLabel = [[UILabel alloc]init];
    [_backImageView addSubview:_mailLabel];
    [_mailLabel release];
    _likeLabel = [[UILabel alloc]init];
    [_backImageView addSubview:_likeLabel];
    [_likeLabel release];
    _youImageView = [[UIImageView alloc]init];
    [_backImageView addSubview:_youImageView];
    [_youImageView release];
    
    
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    _backImageView.frame = CGRectMake(10 * W, 5 * H, self.contentView.frame.size.width - 20 * W, 90 * H);
    _ImageView.frame = CGRectMake(0, 0, _backImageView.frame.size.height, _backImageView.frame.size.height);
    _nameLabel.frame = CGRectMake(_ImageView.frame.origin.x + _ImageView.frame.size.width + 10 * W, _ImageView.frame.origin.y, _backImageView.frame.size.width - _ImageView.frame.size.width - 15 * W, 30 * H);
    _timeLabel.frame = CGRectMake(_nameLabel.frame.origin.x, _nameLabel.frame.origin.y + _nameLabel.frame.size.height + 10 * H, _nameLabel.frame.size.width - 30 * W, 10 * H);
    _youImageView.frame = CGRectMake(_timeLabel.frame.origin.x + _timeLabel.frame.size.width, _timeLabel.frame.origin.y, 20 * W, 20 * H);
    _dianLabel.frame = CGRectMake(_timeLabel.frame.origin.x, _timeLabel.frame.origin.y + _timeLabel.frame.size.height + 20 * H, 80 * W, 10 * H);
    _mailLabel.frame = CGRectMake(_dianLabel.frame.origin.x + _dianLabel.frame.size.width, _dianLabel.frame.origin.y, _dianLabel.frame.size.width, _dianLabel.frame.size.height);
    _likeLabel.frame = CGRectMake(_mailLabel.frame.origin.x + _mailLabel.frame.size.width, _mailLabel.frame.origin.y, _mailLabel.frame.size.width, _mailLabel.frame.size.height);
}
-(void)setSearch:(SearchTrips *)search
{
    if (_search != search) {
        [_search release];
        _search = [search retain];
    }
    _backImageView.backgroundColor = [UIColor whiteColor];
    [_ImageView sd_setImageWithURL:[NSURL URLWithString:_search.cover_image] placeholderImage:[UIImage imageNamed:@"dengdai"]];
    _nameLabel.text = _search.name;
    _nameLabel.font = [UIFont systemFontOfSize:15];
    _timeLabel.text = [NSString stringWithFormat:@"历时: %@ 天", _search.day_count];
    _timeLabel.font = [UIFont systemFontOfSize:11];
    _dianLabel.text = [NSString stringWithFormat:@"景点: %@", _search.waypoints];
    _dianLabel.font = [UIFont systemFontOfSize:11];

    _mailLabel.text = [NSString stringWithFormat:@"里程: %ld", [_search.mileage integerValue]];
    _mailLabel.font = [UIFont systemFontOfSize:11];
    _likeLabel.text = [NSString stringWithFormat:@"推荐: %@", _search.recommendations];
    _likeLabel.font = [UIFont systemFontOfSize:11];
    _youImageView.image = [UIImage imageNamed:@"xiangyou"];
    
}














- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
